/*
 * Copyright (C) 2014 STNet,Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package jp.co.stnet.apps.medcloud.domain.beans;

import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import jp.co.stnet.apps.medcloud.domain.entities.MUser;

/**
 * 認証ユーザー情報を保持するクラスです。
 *
 * @author stnetadmin
 */
public class UserProfile implements UserDetails {

    private static final List<? extends GrantedAuthority> DEFAULT_AUTHORITIES = Collections
            .singletonList(new SimpleGrantedAuthority("ROLE_USER"));

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return DEFAULT_AUTHORITIES;
    }

    @Override
    public String getPassword() {
        return getPw();
    }

    @Override
    public String getUsername() {
        return getLoginId();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.login_id
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private String loginId;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.pw
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private String pw;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.tmp_pw
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private String tmpPw;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.tmp_pw_issue_time
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private Date tmpPwIssueTime;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.usr_name_kanji
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private String usrNameKanji;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.usr_name_kana
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private String usrNameKana;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.usr_birth_year
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private Short usrBirthYear;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.usr_birth_month
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private Short usrBirthMonth;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.usr_birth_day
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private Short usrBirthDay;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.usr_sex
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private Short usrSex;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.request_status
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private Short requestStatus;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.mail_addr
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private String mailAddr;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.create_time
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private Date createTime;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.update_time
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private Date updateTime;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.create_user
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private String createUser;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.update_user
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private String updateUser;

    /**
     * This field was generated by MyBatis Generator. This field corresponds to
     * the database column public.m_user.del_flg
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    private Boolean delFlg;

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.login_id
     *
     * @return the value of public.m_user.login_id
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public String getLoginId() {
        return loginId;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.login_id
     *
     * @param loginId the value for public.m_user.login_id
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setLoginId(String loginId) {
        this.loginId = loginId == null ? null : loginId.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.pw
     *
     * @return the value of public.m_user.pw
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public String getPw() {
        return pw;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.pw
     *
     * @param pw the value for public.m_user.pw
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setPw(String pw) {
        this.pw = pw == null ? null : pw.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.tmp_pw
     *
     * @return the value of public.m_user.tmp_pw
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public String getTmpPw() {
        return tmpPw;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.tmp_pw
     *
     * @param tmpPw the value for public.m_user.tmp_pw
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setTmpPw(String tmpPw) {
        this.tmpPw = tmpPw == null ? null : tmpPw.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.tmp_pw_issue_time
     *
     * @return the value of public.m_user.tmp_pw_issue_time
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public Date getTmpPwIssueTime() {
        return tmpPwIssueTime;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.tmp_pw_issue_time
     *
     * @param tmpPwIssueTime the value for public.m_user.tmp_pw_issue_time
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setTmpPwIssueTime(Date tmpPwIssueTime) {
        this.tmpPwIssueTime = tmpPwIssueTime;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.usr_name_kanji
     *
     * @return the value of public.m_user.usr_name_kanji
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public String getUsrNameKanji() {
        return usrNameKanji;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.usr_name_kanji
     *
     * @param usrNameKanji the value for public.m_user.usr_name_kanji
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setUsrNameKanji(String usrNameKanji) {
        this.usrNameKanji = usrNameKanji == null ? null : usrNameKanji.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.usr_name_kana
     *
     * @return the value of public.m_user.usr_name_kana
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public String getUsrNameKana() {
        return usrNameKana;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.usr_name_kana
     *
     * @param usrNameKana the value for public.m_user.usr_name_kana
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setUsrNameKana(String usrNameKana) {
        this.usrNameKana = usrNameKana == null ? null : usrNameKana.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.usr_birth_year
     *
     * @return the value of public.m_user.usr_birth_year
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public Short getUsrBirthYear() {
        return usrBirthYear;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.usr_birth_year
     *
     * @param usrBirthYear the value for public.m_user.usr_birth_year
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setUsrBirthYear(Short usrBirthYear) {
        this.usrBirthYear = usrBirthYear;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.usr_birth_month
     *
     * @return the value of public.m_user.usr_birth_month
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public Short getUsrBirthMonth() {
        return usrBirthMonth;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.usr_birth_month
     *
     * @param usrBirthMonth the value for public.m_user.usr_birth_month
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setUsrBirthMonth(Short usrBirthMonth) {
        this.usrBirthMonth = usrBirthMonth;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.usr_birth_day
     *
     * @return the value of public.m_user.usr_birth_day
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public Short getUsrBirthDay() {
        return usrBirthDay;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.usr_birth_day
     *
     * @param usrBirthDay the value for public.m_user.usr_birth_day
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setUsrBirthDay(Short usrBirthDay) {
        this.usrBirthDay = usrBirthDay;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.usr_sex
     *
     * @return the value of public.m_user.usr_sex
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public Short getUsrSex() {
        return usrSex;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.usr_sex
     *
     * @param usrSex the value for public.m_user.usr_sex
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setUsrSex(Short usrSex) {
        this.usrSex = usrSex;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.request_status
     *
     * @return the value of public.m_user.request_status
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public Short getRequestStatus() {
        return requestStatus;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.request_status
     *
     * @param requestStatus the value for public.m_user.request_status
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setRequestStatus(Short requestStatus) {
        this.requestStatus = requestStatus;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.mail_addr
     *
     * @return the value of public.m_user.mail_addr
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public String getMailAddr() {
        return mailAddr;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.mail_addr
     *
     * @param mailAddr the value for public.m_user.mail_addr
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setMailAddr(String mailAddr) {
        this.mailAddr = mailAddr == null ? null : mailAddr.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.create_time
     *
     * @return the value of public.m_user.create_time
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.create_time
     *
     * @param createTime the value for public.m_user.create_time
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.update_time
     *
     * @return the value of public.m_user.update_time
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public Date getUpdateTime() {
        return updateTime;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.update_time
     *
     * @param updateTime the value for public.m_user.update_time
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.create_user
     *
     * @return the value of public.m_user.create_user
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public String getCreateUser() {
        return createUser;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.create_user
     *
     * @param createUser the value for public.m_user.create_user
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setCreateUser(String createUser) {
        this.createUser = createUser == null ? null : createUser.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.update_user
     *
     * @return the value of public.m_user.update_user
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public String getUpdateUser() {
        return updateUser;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.update_user
     *
     * @param updateUser the value for public.m_user.update_user
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser == null ? null : updateUser.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column public.m_user.del_flg
     *
     * @return the value of public.m_user.del_flg
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public Boolean getDelFlg() {
        return delFlg;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column public.m_user.del_flg
     *
     * @param delFlg the value for public.m_user.del_flg
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    public void setDelFlg(Boolean delFlg) {
        this.delFlg = delFlg;
    }

    /**
     * This method was generated by MyBatis Generator. This method corresponds
     * to the database table public.m_user
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        MUser other = (MUser) that;
        return (this.getLoginId() == null ? other.getLoginId() == null : this.getLoginId().equals(other.getLoginId()))
                && (this.getPw() == null ? other.getPw() == null : this.getPw().equals(other.getPw()))
                && (this.getTmpPw() == null ? other.getTmpPw() == null : this.getTmpPw().equals(other.getTmpPw()))
                && (this.getTmpPwIssueTime() == null ? other.getTmpPwIssueTime() == null : this.getTmpPwIssueTime().equals(other.getTmpPwIssueTime()))
                && (this.getUsrNameKanji() == null ? other.getUsrNameKanji() == null : this.getUsrNameKanji().equals(other.getUsrNameKanji()))
                && (this.getUsrNameKana() == null ? other.getUsrNameKana() == null : this.getUsrNameKana().equals(other.getUsrNameKana()))
                && (this.getUsrBirthYear() == null ? other.getUsrBirthYear() == null : this.getUsrBirthYear().equals(other.getUsrBirthYear()))
                && (this.getUsrBirthMonth() == null ? other.getUsrBirthMonth() == null : this.getUsrBirthMonth().equals(other.getUsrBirthMonth()))
                && (this.getUsrBirthDay() == null ? other.getUsrBirthDay() == null : this.getUsrBirthDay().equals(other.getUsrBirthDay()))
                && (this.getUsrSex() == null ? other.getUsrSex() == null : this.getUsrSex().equals(other.getUsrSex()))
                && (this.getRequestStatus() == null ? other.getRequestStatus() == null : this.getRequestStatus().equals(other.getRequestStatus()))
                && (this.getMailAddr() == null ? other.getMailAddr() == null : this.getMailAddr().equals(other.getMailAddr()))
                && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
                && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
                && (this.getCreateUser() == null ? other.getCreateUser() == null : this.getCreateUser().equals(other.getCreateUser()))
                && (this.getUpdateUser() == null ? other.getUpdateUser() == null : this.getUpdateUser().equals(other.getUpdateUser()))
                && (this.getDelFlg() == null ? other.getDelFlg() == null : this.getDelFlg().equals(other.getDelFlg()));
    }

    /**
     * This method was generated by MyBatis Generator. This method corresponds
     * to the database table public.m_user
     *
     * @mbggenerated Fri Jun 27 10:55:53 JST 2014
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getLoginId() == null) ? 0 : getLoginId().hashCode());
        result = prime * result + ((getPw() == null) ? 0 : getPw().hashCode());
        result = prime * result + ((getTmpPw() == null) ? 0 : getTmpPw().hashCode());
        result = prime * result + ((getTmpPwIssueTime() == null) ? 0 : getTmpPwIssueTime().hashCode());
        result = prime * result + ((getUsrNameKanji() == null) ? 0 : getUsrNameKanji().hashCode());
        result = prime * result + ((getUsrNameKana() == null) ? 0 : getUsrNameKana().hashCode());
        result = prime * result + ((getUsrBirthYear() == null) ? 0 : getUsrBirthYear().hashCode());
        result = prime * result + ((getUsrBirthMonth() == null) ? 0 : getUsrBirthMonth().hashCode());
        result = prime * result + ((getUsrBirthDay() == null) ? 0 : getUsrBirthDay().hashCode());
        result = prime * result + ((getUsrSex() == null) ? 0 : getUsrSex().hashCode());
        result = prime * result + ((getRequestStatus() == null) ? 0 : getRequestStatus().hashCode());
        result = prime * result + ((getMailAddr() == null) ? 0 : getMailAddr().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        result = prime * result + ((getCreateUser() == null) ? 0 : getCreateUser().hashCode());
        result = prime * result + ((getUpdateUser() == null) ? 0 : getUpdateUser().hashCode());
        result = prime * result + ((getDelFlg() == null) ? 0 : getDelFlg().hashCode());
        return result;
    }

}
